package com.javaclimb.drug.common;

import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.HashMap;
import java.util.List;

/**
 * 给前端返回的json格式数据
 */
public class ResultMapUtil {

    /**
     * 登录返回结果
     */
    public static HashMap<String,Object> getHashMapLogin(String msg,String code){
        HashMap<String,Object> resultMap = new HashMap<>();
        resultMap.put("msg",msg);
        resultMap.put("code",code);
        if("1".equals(code)){
            resultMap.put("icon",1);
        }else {
            resultMap.put("icon",3);
        }
        resultMap.put("anim",4);
        return resultMap;
    }

    /**
     * 分页查询结果
     */
    public static HashMap<String,Object> getHashMapMysqlPage(IPage<?> object){
        HashMap<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        resultMap.put("msg","");
        resultMap.put("count",object.getTotal());
        resultMap.put("data",object.getRecords());
        return resultMap;
    }

    /**
     * 异常数据统一处理
     */
    public static HashMap<String,Object> getHashMapException(Exception e){
        HashMap<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        resultMap.put("msg",e.getMessage());
        return resultMap;
    }

    /**
     * 保存成功的统一返回格式
     */
    public static HashMap<String,Object> getHashMapSave(int i){
        HashMap<String,Object> resultMap = new HashMap<>();
        if(i == 0){
            resultMap.put("msg","保存失败");
            resultMap.put("code",1);
            resultMap.put("icon",5);
            resultMap.put("anim",6);
        }else {
            resultMap.put("msg","保存成功");
            resultMap.put("code",0);
            resultMap.put("icon",1);
            resultMap.put("anim",4);
        }
        return resultMap;
    }

    /**
     * 删除成功的统一返回格式
     */
    public static HashMap<String,Object> getHashMapDel(int i){
        HashMap<String,Object> resultMap = new HashMap<>();
        if(i == 0){
            resultMap.put("msg","删除失败");
            resultMap.put("code",1);
            resultMap.put("icon",5);
            resultMap.put("anim",6);
        }else {
            resultMap.put("msg","删除成功");
            resultMap.put("code",0);
            resultMap.put("icon",1);
            resultMap.put("anim",4);
        }
        return resultMap;
    }

    /**
     * List返回格式
     */
    public static HashMap<String,Object> getHashMapList(List<?> list){
        HashMap<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        if(list!=null&&list.size()>0){
            resultMap.put("msg","");
        }else {
            resultMap.put("msg","没有查询到数据！");
        }
        resultMap.put("data",list);
        return resultMap;
    }
    /**
     * 上传返回结果
     */
    public static HashMap<String,Object> getHashMapUpload(Integer i,Object path){
        HashMap<String,Object> resultMap = new HashMap<>();
        if(i == 0){
            resultMap.put("msg","上传失败");
            resultMap.put("code",0);
            resultMap.put("icon",5);
        }else {
            resultMap.put("msg","上传成功");
            resultMap.put("code",1);
            resultMap.put("icon",1);
            resultMap.put("data",path);
        }
        return resultMap;
    }
    /**
     * 公共map
     */
    public static HashMap<String,String> getImgInfo(String str){
        HashMap<String,String> map = new HashMap<String, String>();

        if(str.equals("0") || str.contains("Black_Footed")){
            map.put("src1","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0023_796059.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0025_796057.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0032_796115.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0038_212.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0045_796129.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/Black_Footed_Albatross/Black_Footed_Albatross_0050_796125.jpg");
            map.put("name1","鸭1");
            map.put("name2","鸭2");
            map.put("name3","鸭3");
            map.put("name4","鸭4");
            map.put("name5","鸭5");
            map.put("name6","鸭6");
        }else if(str.equals("1") || str.contains("cow")){
            map.put("src1","../static/layui/css/modules/layer/default/query/cow/cow_10315.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/cow/cow_10428.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/cow/cow_10536.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/cow/cow_10780.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/cow/cow_10871.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/cow/cow_11109.jpg");
            map.put("name1","牛1");
            map.put("name2","牛2");
            map.put("name3","牛3");
            map.put("name4","牛4");
            map.put("name5","牛5");
            map.put("name6","牛6");
        }else if(str.equals("2") || str.contains("fox")){
            map.put("src1","../static/layui/css/modules/layer/default/query/fox/fox_10023.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/fox/fox_10036.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/fox/fox_10208.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/fox/fox_10237.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/fox/fox_10489.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/fox/fox_10654.jpg");
            map.put("name1","狐1");
            map.put("name2","狐2");
            map.put("name3","狐3");
            map.put("name4","狐4");
            map.put("name5","狐5");
            map.put("name6","狐6");
        }else if(str.equals("3") || str.contains("Mallard")){
            map.put("src1","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0038_76902.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0044_76317.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0050_76519.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0089_77068.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0103_77105.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/Mallard/Mallard_0123_76653.jpg");
            map.put("name1","鹅1");
            map.put("name2","鹅2");
            map.put("name3","鹅3");
            map.put("name4","鹅4");
            map.put("name5","鹅5");
            map.put("name6","鹅6");
        }else if(str.equals("4") || str.contains("Prothonotary")){
            map.put("src1","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0004_173475.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0020_174122.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0049_174213.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0058_173440.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0074_173443.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/Prothonotary_Warbler/Prothonotary_Warbler_0109_174121.jpg");
            map.put("name1","鸟1");
            map.put("name2","鸟2");
            map.put("name3","鸟3");
            map.put("name4","鸟4");
            map.put("name5","鸟5");
            map.put("name6","鸟6");
        }else if(str.equals("5") || str.contains("tiger")){
            map.put("src1","../static/layui/css/modules/layer/default/query/tiger/tiger_10180.jpg");
            map.put("src2","../static/layui/css/modules/layer/default/query/tiger/tiger_10328.jpg");
            map.put("src3","../static/layui/css/modules/layer/default/query/tiger/tiger_10495.jpg");
            map.put("src4","../static/layui/css/modules/layer/default/query/tiger/tiger_10662.jpg");
            map.put("src5","../static/layui/css/modules/layer/default/query/tiger/tiger_10721.jpg");
            map.put("src6","../static/layui/css/modules/layer/default/query/tiger/tiger_10790.jpg");
            map.put("name1","虎1");
            map.put("name2","虎2");
            map.put("name3","虎3");
            map.put("name4","虎4");
            map.put("name5","虎5");
            map.put("name6","虎6");
        }else {
            map.put("src1","../static/layui/css/modules/layer/default/background.jpeg");
            map.put("src2","../static/layui/css/modules/layer/default/background.jpeg");
            map.put("src3","../static/layui/css/modules/layer/default/background.jpeg");
            map.put("src4","../static/layui/css/modules/layer/default/background.jpeg");
            map.put("src5","../static/layui/css/modules/layer/default/background.jpeg");
            map.put("src6","../static/layui/css/modules/layer/default/background.jpeg");
        }
        return map;
    }
}




















